//
//  VideoPlayer.m
//  CoJellyCartoon
//
//  Created by kingbw on 16/4/7.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "VideoPlayer.h"

@implementation VideoPlayer

//写单例
+ (instancetype)shareAVPlayer {
    static VideoPlayer *player = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        player = [[VideoPlayer alloc] init];
        
    });
    
    return player;
}

- (void)playWithUrl:(NSString *)url {
    if (self.currentItem) {
        [self replaceCurrentItemWithPlayerItem:self.currentItem];
    }
    AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:url]];
    [self replaceCurrentItemWithPlayerItem:playerItem];
}



@end
